package de.fhhannover.inform.itteam.snmpnetviz.gui;

import java.awt.event.MouseEvent;

import prefuse.Display;
import prefuse.Visualization;
import prefuse.controls.ControlAdapter;
import prefuse.data.Node;
import prefuse.visual.VisualItem;

public class HoverToolTip extends ControlAdapter {
	public void itemEntered(VisualItem item, MouseEvent e) {
		Visualization v = item.getVisualization();
		Display d = v.getDisplay(0);
		Node node = (Node)v.getSourceTuple(item);
		d.setToolTipText("<html>"+
				"<b>IP: </b>"+node.getString("ip")+"<br/>"+
				"<b>Node Name: </b>"+node.getString("name")+"<br/>"+
				"<b>Node Domain: </b>"+node.getString("domain")+"<br/>"+
				"<b>MAC: </b>"+node.getString("mac")+"<br/>"+
				"<b>VLAN: </b>"+node.getInt("vlan")+"<br/>"+
				"<b>Port: </b>"+node.getInt("port")+"<br/>"+
				"<b>Port Beschreibung: </b>"+node.getString("portdesc")+"<br/>"+
				"<b>Node Type: </b>"+node.getString("type")+
				"</html>");
	}

	public void itemExited(VisualItem item, MouseEvent e) {
		Visualization v = item.getVisualization();
		Display d = v.getDisplay(0);
		d.setToolTipText(null);
		v.run("draw");
	}
}